// chapter1_2.cpp : Defines the entry point for the console application.
//


#include "chapter1_2.h"


#ifdef WIN32
	#define M_FUNC __FUNCTION__
	#define M_LINE __LINE__
	#define M_DATE	__DATE__
#elif defined(__ARMCC__)
	#define M_FUNC __func__
	#define M_LINE __line__
	#define M_DATE	__date__
#else
	#error "No platform assigned !"
#endif

using namespace std;/* we can directly use standard c++ classes lib by USING derective ! */





void appendstring(string *str, string append)
{
	*str += append;
}

void appendstring2(string & str, string append)
{
	str += append;
}

void appendstring3(string str, string append)
{
	str += append;
}



void testRefType(int &refInput)
{
	refInput = 0xff;	
}

typedef enum _DATA_TYPE_{
	DATA_TYPE_INT,
	DATA_TYPE_CHAR,
	DATA_TYPE_SHORT,

}DATA_TYPE_E;




char*  MMBBMS_STR_StrCpy(char *dst, const char *src)
{
    char *ret = dst;

    if ((NULL == dst) || (NULL == src))
    {
        return dst;
    }	

    /*lint -e{960} suppess "(Note -- Violates MISRA Required Rule 42, comma operator used outside of 'for' expression)" */
    for (; (*dst = *src) != '\0'; ++src, ++dst)
    {
        /* to make lint happy! */
    }

    return ret;
}/* end of MMBBMS_STR_StrCpy() */


extern void testBaseType();
extern void testDerivedClass();
extern void testBaseClass();
extern void testContainer();
extern void test_overload_operator();
extern void test_template();
extern 	void test_dd();
extern void test_oop();
extern void test_query();
extern void test_rtti();

void _DebugPrint(const char* dbgOutput, ... )
{

#include "stdio.h"
#include "stdarg.h"
	char temp[1024*5] = {0};
	va_list list;

	va_start (list, dbgOutput);

	vsprintf (temp, dbgOutput, list);

	va_end (list);

	OutputDebugStringA(temp);

	return;
} /* end of	_MBBBMS_DebugPrint(	) */

int main()
{
	int a = 1;	
		
	DATA_TYPE_E eDataType = DATA_TYPE_INT;
	std::string thisStr = "Hello, C++ world!!";
	
	const int *pCnstInt;

	char aa[100];
	char *b = "yes,yes";
	MMBBMS_STR_StrCpy(aa, b);

	test_rtti();
	test_query();

	test_oop();
	test_dd();
	test_template();
	
	 int time = 10;
	 const int &refInt = time;
	 const int arraySize = 10;
	 int ab[arraySize];
	 complex< int > cpxA(1 , 2);

	 //testBaseType();
	 //testBaseClass();
	 testDerivedClass();
	 //testContainer();
	 test_overload_operator();

	// refInt += time;

	//pCnstInt = &time;
	//*pCnstInt = 0;

	testRefType(time);
	string tempstr("hi, this is a temp string ! ");
	//Array<int> ia(4);
	string errmsg("test throw");
	string strTbl[10];

	strTbl[0] = "dynamic string input";
	string allstring = thisStr + tempstr + errmsg;
	appendstring(&allstring, "\tend");
	appendstring2(allstring, "\tend");
	appendstring3(allstring, "\tend");
	//throw errmsg;
	if(allstring != "end")
		std::cout<<allstring<<'\n';
	printf("%s", allstring.c_str());
	const char *cstr = allstring.c_str();

	int string = int();

	
	

	
	//baseArray.init(MybaseArray);	
	
	printf("%s, %s, %d,", M_DATE, M_FUNC, M_LINE);
	std::cout<< thisStr <<endl;
	std::cout<< hex << 254 <<endl;


	return 0;
}

